package net.zabuchy.customer.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import net.zabuchy.customer.entity.Customer;
 
public class CustomerDaoImpl extends HibernateDaoSupport implements CustomerDao {
 
    public void add(Customer customer) {
    	logger.debug("customerId: " + customer.getCustomerId());
    	getHibernateTemplate().save(customer);
    	logger.debug("customerId: " + customer.getCustomerId());
    }
 
    public void update(Customer customer) {
    	getHibernateTemplate().update(customer);
    }
 
    public void delete(Customer customer) {
    	getHibernateTemplate().delete(customer);
    }
    
    public void edit(Customer customer) {
    	getHibernateTemplate().update(customer);
    }
 
    public List findAll() {
    	return getHibernateTemplate().find("from Customer");
    }
 
    public Customer findById(int id) {
    	return (Customer) getHibernateTemplate().find("from Customer where CUSTOMER_ID=?", id).get(0);
    }
}